import { RouteRecordNormalized } from 'vue-router';

export function add(a: number, b: number) {
    return a + b;
}

export function getTitle(name: string, routes: RouteRecordNormalized[]) {
    const names: string[] = [];
    // eslint-disable-next-line no-constant-condition
    while (true) {
        names.push(name);
        const currentRouteObj = routes.find((item) => item.name === name);
        const parentRouteObj = routes.find((item) => item.name === currentRouteObj?.meta.parentRouter);
        if (parentRouteObj) {
            name = parentRouteObj.name as string;
            continue;
        } else {
            break;
        }
    }
    return names.reverse();
}
